<?php
/**
Exibe um formul�rio para a altera��o de um setor j� cadastrado no banco de dados.
*/

if(!isset($_SESSION))
{
   session_start();
}

if( !function_exists('__autoload') )
{
    function __autoload($class_name) {
    require_once $class_name . '.php';
    }
}

SAEO::ValidarAcesso( array( 0, 2 ) );

// Descri��es da Ajuda
$ajudaCampus = 'showhint("Escolha a Campus ao qual o setor est� vinculado.", this, event, "220px");';
$ajudaSetor = 'showhint("Escolha o Setor que deseja alterar.", this, event, "220px");';
$ajudaNome = 'showhint("Nome do setor.", this, event, "90px");';
$ajudaResponsavel = 'showhint("Respons�vel pelo setor.", this, event, "140px");';

$campus = new Campus();
$campiCadastradas = $campus->CarregarCampi(); # carrega do banco de dados todas as campi cadastradas e retorna o resultado em um array
?>
<html>
           <head>
           <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
           <title>SAEO - Alterar Setor</title>
           <script type='text/javascript' src='templates/setor.js'></script>
           <script type='text/javascript' src='templates/hintbox.js'></script>
           <script type='text/javascript' src='templates/js.js'></script>
           <script type='text/javascript' src='templates/ajax.js'></script>
           <script type='text/javascript' src='templates/validacoes.js'></script>
           <link rel='stylesheet' type='text/css' href='templates/estilos.css'/>

           </head>
     <body class='body'>
     <form name='alterar_setor' action='EnviarDadosSetor.php?operacao=2' method='post' onsubmit='return ValidarAlteracaoSetor();'>
     <table width='779' border='0' cellspacing='0' cellpadding='0' align='center' bgcolor='#FFFFFF'>
            <tr>
                <td colspan='2'><?php include "Topo.php"; ?></td>
            </tr>
            <tr>
                <td colspan='2'><div class='titulosTabelas' style='width:779; height:20; background:url(templates/tabela.jpg)'>ALTERA&Ccedil;&Atilde;O DE SETOR</div></td>
            </tr>
            <tr>
                <td colspan='2'>&nbsp;</td>
            </tr>
            <tr>
                <td colspan='2'><table class='tabela' width='650' border='0' cellspacing='0' cellpadding='0' align='center' bgcolor='#FFFFFF'>
                           <tr>
                               <td colspan='2'>&nbsp;</td>
                           </tr>
                           <tr>
                               <td class='textoTabelas' width='20%'>&nbsp;Unidade:</td>
                               <td class='textoTabelas'>
                                   <select name='campi' id='campi' class='inputTexto' style='width:300px' onchange='EsconderDiv(getElementById("informacaoSetor")); CarregarSetores( this.value );' >
                                           <option value='0'>Selecione a unidade</option>
                                           <?php 
		                                   # percorre o array de campi criando elementos opcoes para o elemento select
		                                   for( $i = 0; $i < count( $campiCadastradas ) ; $i++ )
												echo " <option value='".$campiCadastradas[$i]->id."'>".$campiCadastradas[$i]->nome."</option> ";
		                                   ?>
                                   </select>
                                   <a href='#' class='hintanchor' onMouseover='<?php echo $ajudaCampus ?>'>[?]</a>
                               </td>
                           </tr>
                           <tr>
                               <td colspan='2'>&nbsp;</td>
                           </tr>
                           <tr>
                               <td class='textoTabelas'>&nbsp;Setor: </td>
                               <td class='textoTabelas'>
                               <select name='setores' id='listaSetores' class='inputTexto' onchange='MostrarDiv ( this.value, getElementById("informacaoSetor")); CarregarSetor(this.value);'>
                                       <option id='setor' value='0'>Primeiro selecione a Campus</option>
                               </select>
                               <a href='#' class='hintanchor' onMouseover='<?php echo $ajudaSetor ?>'>[?]</a>
                               </td>
                           </tr>
                           <tr>
                               <td colspan='2'>&nbsp;</td>
                           </tr>
                            <tr>
                               <td colspan='2'>
                                   <div id='informacaoSetor' style='display:none;'>
                                   <input type='hidden' name='setorId' id='setorId'>
                                   <table class='tabela' width='650' style='border-style: none' border='0' cellspacing='0' cellpadding='0' align='center' bgcolor='#FFFFFF'>
                                          <tr>
                                              <td class='textoTabelas' width='20%'>&nbsp;Nome: </td>
                                              <td class='textoTabelas'><input type='text' name='setorNome' id='setorNome' maxlength='255' class='inputTexto' style='width:260' > <a href='#' class='hintanchor' onMouseover='<?php echo $ajudaNome ?>'>[?]</a></td>
                                          </tr>
                                          <tr>
                                              <td colspan='2'>&nbsp;</td>
                                          </tr>
                                          <tr>
                                              <td class='textoTabelas' width='20%'>&nbsp;Respons&aacute;vel: </td>
                                              <td class='textoTabelas'><input type='text' name='setorResponsavel' id='setorResponsavel' class='inputTexto' maxlength='255' style='width:260' > <a href='#' class='hintanchor' onMouseover='<?php echo $ajudaResponsavel ?>'>[?]</a></td>
                                          </tr>
                                          <tr>
                                              <td colspan='2'>&nbsp;</td>
                                          </tr>
                                          <tr>
                                              <td colspan='2' height='46'><input type='image' style='width:100px;height:30px;position:relative;left:540px' src='templates/btavancar.JPG'/></td>
                                          </tr>
                                   </table>
                               </div>
                               </td>
                           </tr>
                     </table>
                </td>
            </tr>
            <tr>
                <td colspan='2'>&nbsp;</td>
            </tr>
            <tfoot>
                   <tr>
                   		<td><?php include 'rodapeCreditos.php'; ?></td>
                   </tr>
            </tfoot>
     </table>
     </body>
     </html>
